$(function () {
    var currentnum,
        // 获取产品类别
        allCategoryApi = '/category/searchAllMeatCategory',
        // 获取 产地
        allPlaceApi = '/goodsLocus/searchAllGoodsLocus',
        meatType =Number(getQueryString('meatType')) || 0,
        // 获取输入框 匹配模糊搜索
        categoryApi = '/ category/getMeatCategoryInfos',
        dataTypes = '',
        outWall = '/country/getCountryInfos',
        // 搜索数据
        getUrl = '/home/searchPurchaseInfos',    // 页面list数据接口地址
        meatTypes =meatType || 0,
        jrollinit = null,
        container = $('#meal-info section'),
        updateDate =getQueryString('updateDate') || 30,
        provideWay =getQueryString('provideWay') || '',
        country= getQueryString('country') || '',
        amountReverse = getQueryString('amountReverse') || '' ,
        priceReverse = getQueryString('priceReverse') || '',
        deliveryArea = getQueryString('deliveryArea') || '',
        meatTypeDetails =  getQueryString('meatTypeDetails') || '',
        packingId = getQueryString('packingId') || '',
        factoryNo = getQueryString('factoryNo') || '',
        keyWord = getQueryString('keyWord') || '',
        numflag,
        reSet = function () {
            jrollinit.destroy();
            $('#meal-info').empty()
            $('#meal-info').append($('<div class="container" id="scroller"></div>'));
            jroll();
            jrollinit.refresh();
            share(keyWord,dataTypes,meatType);
        },
        setmeatType = function (obj) {
            // "uuid" : "xxxx",            //用户uuid
            //     "signature" : "xxx",        //访问签名
            // "deliveryArea":"北京"          // 所在地的搜索
            obj.meatTypes = obj.meatTypes ? obj.meatTypes : 0;
            obj.pageSize = obj.pageSize ? obj.pageSize : 10;
            obj.updateDate = obj.updateDate== '不限' ?'': obj.updateDate?obj.updateDate:'';
            obj.offset = obj.offset ? obj.offset : 0;
            obj.provideWay = obj.provideWay ? obj.provideWay : '';      //供货方式：期货 现货
            obj.keyWord = obj.keyWord ? obj.keyWord : '';
            obj.country = obj.country ? obj.country : '';           //产地:可以传入国内 国外  或具体的国家名称
            obj.amountReverse = amountReverse; // 数量排序
            obj.priceReverse = priceReverse; // 价格排序
            obj.deliveryArea = obj.deliveryArea ? obj.deliveryArea : '';         // 所在地
            obj.packingId = obj.packingId? obj.packingId:'';
            obj.factoryNo = obj.factoryNo? obj.factoryNo:'';
            obj.meatTypeDetails = obj.meatTypeDetails ? obj.meatTypeDetails : '';
            dataTypes = "meatType=" + obj.meatTypes +"&factoryNo=" + obj.factoryNo+"&packingId=" + obj.packingId+"&deliveryArea=" + obj.deliveryArea+"&priceReverse=" + obj.priceReverse+"&amountReverse=" + obj.amountReverse+"&provideWay=" + obj.provideWay+ "&meatTypeDetails=" + obj.meatTypeDetails+ "&pageSize=" + obj.pageSize + "&offset=" + obj.offset + "&updateDate=" + obj.updateDate + "&keyWord=" + obj.keyWord + "&country=" + obj.country;
            share(keyWord,dataTypes,meatType);
            return dataTypes;
        },
        requestData = function (obj,fun) {
            $.ajax({
                url: host + getUrl,
                type: 'post',
                data: obj,
                success: function (data) {
                    fun(data)
                }
            });
        },
        filePage = function () {
            var orderBuyindexData = JSON.parse(window.sessionStorage.getItem('orderBuyindexData'));
            meatType = orderBuyindexData.meatTypes;
            window.sessionStorage.removeItem('orderBuyhistory')
            window.sessionStorage.removeItem('orderBuyindexData')
            $('#nav .searchI li').each(function () {
                $(this).removeClass()
                if($(this).index()===meatType) $(this).addClass('font_color radius' +(+meatType+1) );
            })
            jrollinit.scroller.innerHTML = orderBuyindexData.data;
            jrollinit.options.page = orderBuyindexData.page;
            var scrolltop = -($('#meal-info li[data-id='+orderBuyindexData.id+']').offset().top - 110)
            jrollinit.refresh();
            if(orderBuyindexData.current >= 5){
                requestData(setmeatType({
                    meatTypes: meatType,
                    offset: jrollinit.options.page,
                    updateDate : updateDate,
                    provideWay : provideWay,
                    country : country,
                    amountReverse : amountReverse,
                    priceReverse : priceReverse,
                    deliveryArea : deliveryArea,
                    meatTypeDetails : meatTypeDetails,
                    packingId : packingId,
                    factoryNo:factoryNo,
                    keyWord : keyWord
                }),function (data) {
                    if (data.success == true) {
                        jrollinit.options.page += 1
                        jrollinit.infinite_callback(data.data)
                        jrollinit.refresh();
                        jrollinit.scrollTo(0, scrolltop, 0, false, function() {
                            //滑动结束后执行
                            lay.msg('已返回到之前浏览的位置')
                        });
                    } else {
                        //无数据则返回什么
                        console.log(data)
                    }
                });
            }else {
                jrollinit.scrollTo(0, scrolltop, 0, false, function () {
                    //滑动结束后执行
                    lay.msg('已返回到之前浏览的位置')
                    // });
                })
            }
        };


    // 导航栏 搜索点击
    $('.searchBox').on('click', function () {
        searchPublish()
    })
    // 渲染筛选列表
    if(meatType==0) {
        $('#nav .searchI li').removeClass('font_color').eq(0).addClass('font_color')
    }else {
        $('#nav .searchI li').removeClass('font_color').eq(1).addClass('font_color')
    }

    $('.search .top span').on('click', function () {
        $(".search").animate({"width": "0px"},100);
    })
    $('.search .search-r').on('click', function () {
        $(".search").animate({"width": "0px"},100);
    })
    $('#nav .term li').eq(3).on('click', function () {
        var num = meatType,
            show = function () {
                $('.item-leibie').addClass('hidden')
                $('.item-data').removeClass('hidden')
                $('.main-l li').removeClass('active')
            }, m, c,u,d;
        if(numflag === num){
            $(".search").animate({"width": "100%"},100);
            return
        }
        // 产品类别
        $.getJSON(host + allCategoryApi, function (data) {
            var htmlStr = '<ul class="searchItim"><li data-id="0" class="check"><a href="javascript:;">不限</a> </li>',
                contentBox = $('.item-leibie').eq(0),
                parseData = function (data) {
                    var data = data.childrenList?data.childrenList:data;
                    for(var i = 0; i < data.length; i++){
                        if(data[i].childrenList.length){
                            htmlStr += '<li><a href="javascript:;">'+data[i].meatName+'</a> <ul style="display: none;">'
                            parseData(data[i].childrenList)
                            htmlStr += '</ul></li>'
                        }else {
                            htmlStr += '<li data-id='+data[i].id+' class="check"><a href="#">'+data[i].meatName+'</a></li>'
                        }
                    }
                }
            if (data.success) {
                numflag = num;
                parseData(data.data[meatType])
                htmlStr += '</ul>'
                contentBox.append(htmlStr)

                // 手风琴效果
                $('.searchItim', contentBox).accordion({
                    //accordion: true,
                    speed: 100,
                    closedSign: '[+]',
                    openedSign: '[-]'
                })
                // 点击事件
                $('.check', contentBox).on('touchstart', function () {
                    $(this).find('a').css('backgroundColor','#eee')
                })
                $('.check', contentBox).on('touchend', function () {
                    $(this).find('a').css('backgroundColor','transparent')
                })
                $('.check', contentBox).on('click', function () {
                    $('.check', contentBox).removeClass('checked');
                    $(this).addClass('checked')
                    $('.main-l ul li').eq(currentnum).addClass('currentFix')
                    $(this).find('a').css('backgroundColor','transparent')
                    $('.item-data ul').children().eq(currentnum).text($(this).text())
                    $('.icon-search input[name="leibie"]').val($(this).text())
                    show()
                    m = $(this).text().trim();
                    m = m=='不限'?'':m;
                })

            } else {
                console.log(data.message)
            }
        })

        // 产地
        $.getJSON(host + outWall, function (data) {
            var htmlStr = '<ul class="searchItim"><li class="check" data-id="0"><a href="javascript:;">不限</a> </li>',
                contentBox = $('.item-leibie').eq(1),
                parseData = function (data) {
                    var inWallLi = '<li><a href="javascript:;">国内</a><ul style="display: none;">',
                        outWallLi = '<li><a href="javascript:;">国外</a><ul style="display: none;">';
                    for(var i = 2;i < data.length; i++){
                        var str = '<li class="check" data-id='+data[i].id+' ><a href="javascript:;">'+data[i].countryName+'</a></li>'
                        if(data[i].parentId === 1){
                            inWallLi += str;
                        }else {
                            outWallLi += str;
                        }

                    }
                    inWallLi += '</ul>';
                    outWallLi += '</ul>';
                    htmlStr += inWallLi + outWallLi;
                }
            if (data.success) {
                parseData(data.data)
                htmlStr += '</ul>'
                contentBox.append(htmlStr)

                // // 手风琴效果
                $('.searchItim', contentBox).accordion({
                    //accordion: true,
                    speed: 100,
                    closedSign: '[+]',
                    openedSign: '[-]'
                })
                // 点击事件
                $('.check', contentBox).on('touchstart', function () {
                    $(this).find('a').css('backgroundColor','#eee')
                })
                $('.check', contentBox).on('touchend', function () {
                    $(this).find('a').css('backgroundColor','transparent')
                })
                $('.check', contentBox).on('click', function () {
                    $('.check', contentBox).removeClass('checked');
                    $(this).addClass('checked')
                    $('.main-l ul li').eq(currentnum).addClass('currentFix')
                    $(this).find('a').css('backgroundColor','transparent')
                    $('.item-data ul').children().eq(currentnum).text($(this).text())
                    show()
                    c = $(this).text().trim();
                    c = c=='不限'?'':c;
                })
            } else {
                console.log(data.message)
            }
        })

        //  交货地搜索
        $.getJSON(host + allPlaceApi, function (data) {
            var htmlStr = '<ul class="searchItim"><li class="check" data-id="0"><a href="javascript:;">不限</a> </li>',
                nexBox = $('.item-leibie').eq(3),
                parseData = function (data) {
                    for(var i = 0; i < data.length; i++){
                        if(data[i].childrenList.length){
                            htmlStr += '<li><a href="javascript:;">'+data[i].goodsLocusName+'</a> <ul style="display: none;">'
                            parseData(data[i].childrenList)
                            htmlStr += '</ul></li>'
                        }else {
                            htmlStr += '<li data-id='+data[i].id+' class="check"><a href="#">'+data[i].goodsLocusName+'</a></li>'
                        }
                    }
                }
            if (data.success) {
                parseData(data.data)
                htmlStr += '</ul>'
                nexBox.append(htmlStr)
                // 手风琴效果
                $('.searchItim', nexBox).accordion({
                    //accordion: true,
                    speed: 100,
                    closedSign: '[+]',
                    openedSign: '[-]'
                })
                // 点击事件
                $('.check', nexBox).on('touchstart', function () {
                    $(this).find('a').css('backgroundColor','#eee')
                })
                $('.check', nexBox).on('touchend', function () {
                    $(this).find('a').css('backgroundColor','transparent')
                })
                $('.check', nexBox).on('click', function () {
                    $('.check', nexBox).removeClass('checked');
                    $(this).addClass('checked')
                    $(this).find('a').css('backgroundColor','transparent')
                    $('.main-l ul li').eq(currentnum).addClass('currentFix')
                    $('.item-data ul').children().eq(currentnum).text($(this).text())
                    show()
                    d = $(this).text().trim();
                    d = d=='不限'?'':d;
                })

            } else {
                console.log(data.message)
            }
        })
       // 其他点击事件
        $('.check', $('.item-leibie').eq(5)).on('touchstart', function () {
            $(this).find('a').css('backgroundColor','#eee')
        })
        $('.check', $('.item-leibie').eq(5)).on('touchend', function () {
            $(this).find('a').css('backgroundColor','transparent')
        })
        $('.check', $('.item-leibie').eq(5)).on('click', function () {
            $('.check', $('.item-leibie').eq(5)).removeClass('checked');
            $(this).addClass('checked')
            $(this).find('a').css('backgroundColor','transparent')
            $('.main-l ul li').eq(currentnum).addClass('currentFix')
            $('.item-data ul').children().eq(currentnum).text($(this).text())
            show()
            u = $(this).text().trim();
            u = u == '不限'? '不限': parseInt($(this).text().trim()) || '';
        })
        $('input', $('.item-leibie').eq(5)).on('blur', function () {
            $('.main-l ul li').eq(currentnum).addClass('currentFix')
            show()
        })
        $('input', $('.item-leibie').eq(5)).on('input', function () {
            $('.check', $('.item-leibie').eq(5)).removeClass('checked');
            $('.item-data ul').children().eq(currentnum).text($(this).val()+'天内')
            u = parseInt($(this).val().trim())
        })
        $('.main-l li').removeClass('active')
        $(".search").animate({"width": "100%"},100);

        // 点击空白返回
        $('.main-l').on('click', function (e) {
            if(e.pageY > 350){
                show();
            }
        })
        // 按钮点击
        $('.search .footer button').on('click', function () {
            var num = $(this).index();
            if (num === 1) {
                $('.main-r div').eq(0).removeClass('hidden').siblings('div').addClass('hidden')
                $(".search").animate({"width": "0px"});
                updateDate = u?u:updateDate;
                country = c || '';
                deliveryArea = d || '';
                meatTypeDetails = '';
                keyWord = m || '';
                reSet()
            }else {
                $('.main-l ul li').removeClass('currentFix')
                $('.checked').removeClass('checked')
                $('.item-data ul li').text('不限')
                $('.item-data ul li:nth-last-child(1)').text('不限')
                $('.item-leibie').addClass('hidden')
                $('.item-data').removeClass('hidden')
                $('.main-l li').removeClass('active')
                $('.search-main input').val('')
                updateDate = '';
                u = '';
                c = '';
                d = '';
                m = '';
            }
        })

        // 模糊搜索
        $('.icon-search input[name="leibie"]').on('input', function () {
            var val = $(this).val().trim(),
                _this = $(this);
                if(val){
                    $('.item-data ul').children().eq(0).text(val);
                }else {
                    $('.item-data ul').children().eq(0).text('不限');
                }
                m = val;
            if(val){
                $.getJSON(host+categoryApi,{keyWord:val}, function (data) {
                    if(data.success){
                        $('.main-r').addClass('overfl')
                        var numData = data.data.slice(0,10),htmlStr = '';
                        if(numData.length) {
                            $.each(numData, function () {
                                htmlStr += '<li>'+this.meatName+'</li>'
                            })
                        }else{
                            htmlStr +='<p>抱歉，您输入的信息暂时没有显示，我们会尽快添加上的</p>'
                        }

                        _this.siblings('.searchResult').removeClass('hidden').find('ul').html(htmlStr)
                    }else {
                        console.log(data.message)
                    }
                })
            }else {
                _this.siblings('.searchResult').addClass('hidden')
            }
        })

        // 模糊搜索点击事件
        $('.searchResult ul').on('click', 'li', function () {
            var value = $(this).text().trim();
            $(this).addClass('checked').siblings('li').removeClass('checked');
            $('.checked', $('.item-leibie .searchItim').eq(0)).removeClass('checked')
            $('.icon-search input[name="leibie"]').val(value);
            $('.searchResult').addClass('hidden');
            $('.item-data ul').children().eq(0).text(value);
            $('.main-r').removeClass('overfl')
            $('.main-l ul li').eq(currentnum).addClass('currentFix')
            show();
            m = value;
        })
        $('.searchResult button').on('click', function () {
            $('.main-r').removeClass('overfl')
            $('.icon-search input[name="leibie"]').val('')
            $('.searchResult').addClass('hidden')
            $('.item-data ul').children().eq(0).text('不限')
        })
    })


    // 排序价格
    $('#nav .term li').eq(0).on('click', function () {
        // amountReverse = '',

        priceReverse = !priceReverse;
        if(priceReverse) {
            $('.san').eq(0).addClass('toggle-t')
            $('.san').eq(1).removeClass('toggle-b')
        }else {
            $('.san').eq(1).addClass('toggle-b')
            $('.san').eq(0).removeClass('toggle-t')
        }
        reSet()
    })
    // 排序数量
    $('#nav .term li').eq(1).on('click', function () {
        amountReverse = !amountReverse;
        if(!amountReverse) {
            $('.san').eq(3).addClass('toggle-b')
            $('.san').eq(2).removeClass('toggle-t')
        }else {
            $('.san').eq(2).addClass('toggle-t')
            $('.san').eq(3).removeClass('toggle-b')
        }
        // priceReverse = true
        reSet()
    })

    // 重置
    $('#nav .term li').eq(2).on('click', function () {
        $('.searchItim').each(function () {
            var remove = $(this).data('remove')
            if(!remove){
                $(this).remove()
            }
        })
        $('.currentFix').removeClass('currentFix')
        $('.checked').removeClass('checked')
        $('.item-data ul li').text('不限')
        $('.item-leibie').addClass('hidden')
        $('.item-data').removeClass('hidden')
        $('.main-l li').removeClass('active')
        $('.searchInput').val('')
        if(tebTog){
            tebTog = false;
            updateDate = 30;
            $('.item-data ul li:nth-last-child(1)').text('15天内')
            $('.item-leibie:nth-last-child(1) li').eq(5).addClass('checked')
        }else {
            updateDate = '';
        }
        meatTypes= meatType
        provideWay = ''
        country = ''
        amountReverse = ''
        priceReverse = ''
        deliveryArea = ''
        meatTypeDetails = ''
        packingId = ''
        factoryNo = ''
        keyWord = ''
        numflag = false
        $('.san').removeClass('toggle-b')
        $('.san').removeClass('toggle-t')
        // priceReverse = true
        reSet()
    })
    $('.main-l ul li').on('touchstart', function () {
        $(this).addClass('active')
    })
    $('.main-l ul li').on('click', function () {
        $(this).addClass('active').siblings('li').removeClass('active')
//           $('.item-data').addClass('hidden').siblings().removeClass('hidden')
        currentnum = $(this).index()
        $('.item-leibie').eq(currentnum).removeClass('hidden').siblings('div').addClass('hidden')
    })


    var tebTog = false;
    $('#nav .searchI li').on('click', function () {     //切换 tab 栏
        tebTog = true;
        if($(this).hasClass('font_color')) {
            return;
        }
        // breakS = true
        // 给导航添加样式
        $('#nav .searchI li').removeClass('font_color')
        $(this).addClass('font_color')
        if (this.innerText == '羊肉') {
            $(this).addClass('radius2')
            meatType = 1;
        } else {
            $(this).addClass('radius1')
            meatType = 0;
        }
        $('#nav .term li').eq(2).click()
    });
    // 默认首屏渲染
    jroll();
    window.fn = function (Ele) {
        var obj = {
            page:jrollinit.options.page,
            data:jrollinit.scroller.innerHTML,
            id:$(Ele).data('id'),
            search:dataTypes,
            current:$(Ele).index(),
            meatTypes: meatType
        };
        window.sessionStorage.setItem('orderBuyindexData', JSON.stringify(obj))
    }
    function jroll() {
        jrollinit = new JRoll("#meal-info", {
            scrollBarY: true,
            scrollBarFade: true
        });   // jroll 对象

        // // 下拉刷新
        jrollinit.pulldown({
            spinning:false,
            refresh: function(complete) {
                jrollinit.options.page = 1;
                requestData(setmeatType({
                    meatTypes: meatType,
                    offset: jrollinit.options.page - 1,
                    updateDate : updateDate,
                    provideWay : provideWay,
                    country : country,
                    amountReverse : amountReverse,
                    priceReverse : priceReverse,
                    deliveryArea : deliveryArea,
                    meatTypeDetails : meatTypeDetails,
                    packingId : packingId,
                    factoryNo:factoryNo,
                    keyWord : keyWord
                }),function (data) {
                    if (data.success == true) {
                        complete();
                        if(!data.data.length){
                            jrollinit.scroller.innerHTML = '<div id="noIssue" style="text-align: center;margin-top: 100px;"><div><img src="img/noSearch.png"></div><p>暂时没有找到相关信息</p><div class="jroll-infinite-tip"><a href="javascript:;" id="noresult">换个关键词试试</a></div></div>'
                            $('#noresult').on('click', function () {
                                $('#nav .searchBox').click();
                            })
                        }else {
                            jrollinit.scroller.innerHTML = "";    //清空内容
                            jrollinit.infinite_callback(data.data);
                        }
                    } else {
                        //无数据则返回什么
                        console.log(data)
                    }
                });
            },
        });
        // 无限加载
        jrollinit.infinite({
            options: jrollinit,
            completeTip: '<div class=\"jroll-infinite-tip\" style=\"text-align\: center\;\">俺也是有底线的！</div>',
            loadingTip: '<div class=\"jroll-infinite-tip\" style=\"text-align\: center\;\">正在加载...</div>',
            // template: '<li data-id={{=_obj.id}} data-xian={{=_obj.provideWay=="期货"?0:1}} onclick="fn(this)"><a href="deliveryDetails.html?gonghuo=true&id={{=_obj.id}}"><div class="row"><div class="photo"><img src={{=_obj.imageList[0]?_obj.imageList[0]:"img\/defaultImg.png"}}></div><div class="text"><div class="price"><span>￥</span>{{=_obj.price?_obj.price:"议定"}}<span>/吨</span> </div><p class="title">{{=_obj.meatCategory[0]?_obj.meatCategory[0]:"暂无数据"}}</p><p class="time">{{=_obj.updateDate.substr(0,10)}}</p><p><span class="fl">数&nbsp;&nbsp;&nbsp;&nbsp;量：<span class="blue-color">{{=Math.round(_obj.amount / 1000 * 100) / 100}} </span>吨</span><span class="fr">包装：单独包装</span></p><p><span class="fl">所在地：<span>{{=_obj.deliveryArea}} </span></span><span class="fr">产地：{{=_obj.country}}</span></p><div class="xian">{{=_obj.provideWay=="期货"?"期":"现"}}</div></div></div></a> </li>',
            template: "<li data-id={{=_obj.id}} onclick='fn(this)'><div class='row' style='margin: 0;'><div class='text'><div class='price'><span>￥</span>{{=_obj.price?_obj.price:'议定'}}<span>/吨</span></div><h4>{{=_obj.meatCategory[0]?_obj.meatCategory[0]:'暂无数据'}}</h4><p class='time'>{{=time(_obj.updateDate)}}</p><p><span class='fl'>数<span style='visibility: hidden;'>两</span>量：<span class='blue-color'>{{=Math.round(_obj.amount / 1000 * 100) / 100}} </span>吨</span></p><p><span class='fl'>交货地：<span>{{=_obj.deliveryArea}} </span></span><span class='fr'>产品产地：{{=_obj.country}}</span></p><p class='xiangqing'>详情：{{=_obj.purchaseDesc}}</p><a href='wantToBuyInfo1.html?orderBuyhistory=true&id={{=_obj.id}}'>供应</a></div></div></li>",
            getData: function (page, callback) {
                var history = window.sessionStorage.getItem('orderBuyhistory'),indexData;
                if(history){
                    filePage();
                }else {
                    // // 检测数据合法性
                    // if(Number(updateDate) === Number(updateDate) || (Number(meatType) !== 0 || 1)){
                    //     lay.msg('输入非法字符')
                    //     setTimeout(function () {
                    //         window.location.reload();
                    //     },1000)
                    //     return;
                    // }
                    requestData(setmeatType({
                        meatTypes: meatType,
                        offset: page - 1,
                        updateDate : updateDate,
                        provideWay : provideWay,
                        country : country,
                        amountReverse : amountReverse,
                        priceReverse : priceReverse,
                        deliveryArea : deliveryArea,
                        meatTypeDetails : meatTypeDetails,
                        packingId : packingId,
                        factoryNo:factoryNo,
                        keyWord : keyWord
                    }),function (data) {
                        if (data.success == true) {
                            if(!data.total){
                                jrollinit.scroller.innerHTML = '<div id="noIssue" style="text-align: center;margin-top: 100px;"><div><img src="img/noSearch.png"></div><p>暂时没有找到相关信息</p><div class="jroll-infinite-tip"><a href="javascript:;" id="noresult">换个关键词试试</a></div></div>'
                                $('#noresult').on('click', function () {
                                    $('#nav .searchBox').click();
                                })
                            }else{
                                jrollinit.options.total = Math.ceil(data.total / 10);
                                if(page >= jrollinit.options.total){
                                    jrollinit.options.page = jrollinit.options.total;
                                }
                                callback(data.data)
                            }
                        } else {
                            //无数据则返回什么
                            console.log(data)
                        }
                    });
                }
            },
        });

        jrollinit.refresh();
        return jrollinit;
    };
//尾部的点击事件
    $('#footer-nav  div').eq(5).on('click', function () {
        DetLogin(fnPerson);
    })
    function fnPerson() {
        window.location.href = 'personal.html';
    }

})


//分享开始
function geturl_1(endUrl) {
    endUrl = endUrl || '';
    return encodeURIComponent(window.location.origin+window.location.pathname+"?"+endUrl); //返回参数￿
}


function share(mc,end,a){
    a = a===0?'牛肉':'羊肉'
    mc = mc || a;
    mc = mc || a;
    var titleShare = "你想要卖的"+mc+",众多买家重金求购";
    var shareUrl  = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx554a3c93d558ae03&redirect_uri='+geturl_1(end)+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
    var   img='http://m.zhaoniuw.com/img/icon_share.jpg';



    $.ajax({
        url:wechathost+shareurl + shareparm,
        type:'post',
        success:function(res){

            var json = eval('(' + res + ')');
            wx.config({
                debug: false, // 开启调试模￿调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印￿
                appId: 'wx554a3c93d558ae03', // 必填，公众号的唯一标识
                timestamp:json.data.timestamp , // 必填，生成签名的时间￿
                nonceStr: json.data.nonceStr, // 必填，生成签名的随机￿
                signature: json.data.signature,// 必填，签名，见附￿
                jsApiList: [
                    'onMenuShareTimeline',
                    'onMenuShareAppMessage'


                ] // 必填，鿀要使用的JS接口列表，所有JS接口列表见附￿
            });

            wx.ready(function(){


                wx.checkJsApi({
                    jsApiList: ['onMenuShareAppMessage'], // 需要检测的JS接口列表，所有JS接口列表见附￿
                    success: function(res) {


                        // 以键值对的形式返回，可用的api值true，不可用为false
                        // 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
                    }
                });
                wx.onMenuShareTimeline({
                    title: titleShare, // 分享标题
                    link:shareUrl,
                    imgUrl: img, // 分享图标
                    success: function () {

                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调函数
                    }
                });

                wx.onMenuShareAppMessage({
                    title:titleShare, // 分享标题
                    desc: "找牛网清真牛羊肉交易平台,让大家更好、更快、更方便的买货卖货。", // 分享描述
                    link: shareUrl, // 分享链接
                    imgUrl: img, // 分享图标
                    type: '', // 分享类型,music、video或link，不填默认为link
                    dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                    success: function () {
                    },
                    cancel: function () {
                        // 用户取消分享后执行的回调?ǽ敿
                    }
                });


            });

            wx.error(function(res){

            });


        }
    });
}

//分享结束